package com.huawei.appmarket.service.externalapi.control;

import android.app.Activity;
import android.content.IntentFilter;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import o.diu;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.dxx;
import o.dzw;
import o.eox;
import o.ll;

public class HiAppBuoyProtocolChecker extends dxx {
    private static final String TAG = "HiAppBuoyProtocolChecker";
    private b receiver;

    public HiAppBuoyProtocolChecker(@NonNull Activity activity) {
        this.targetActivity = activity;
    }

    private static void queryUserInfo() {
        if (UserSession.getInstance().getStatus() == 4) {
            eox.ˎ(ContentManager.getInstant().getContext(), false);
        }
    }

    private static boolean msgKeyNotValid(String str, String str2) {
        return (dof.ˋ(str) || str.equals(str2)) ? false : true;
    }

    private void continueWithFailed() {
        if (diu.ˊ().ˎ()) {
            Logger.ˎ(TAG, " continueWithFailed, has agree protocol, checkSuccess");
            checkSuccess();
            return;
        }
        checkFailed();
    }

    private void registerProtocolReceiver() {
        ll ˏ = ll.ˏ(ContentManager.getInstant().getContext());
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.huawei.appmarket.startup.flow.interrupt");
        intentFilter.addAction("com.huawei.appmarket.startup.flow.end");
        intentFilter.addAction("com.huawei.appmarket.startup.flow.error");
        this.receiver = new b(this, this);
        this.receiver.ˎ(TAG);
        ˏ.ˏ(this.receiver, intentFilter);
    }

    private void unregisterProtocolReceiver() {
        if (this.receiver != null) {
            ll.ˏ(ContentManager.getInstant().getContext()).ˋ(this.receiver);
            this.receiver = null;
        }
    }

    public String getName() {
        return "ProtocolChecker";
    }

    public void onDestroy() {
        super.onDestroy();
        unregisterProtocolReceiver();
    }

    public void doCheck() {
        Logger.ˎ(TAG, "check");
        if (diu.ˊ().ˎ()) {
            Logger.ˎ(TAG, "check onAgree ");
            checkSuccess();
            return;
        }
        registerProtocolReceiver();
        Logger.ˎ(TAG, "check not agree");
        dzw.ॱ(this.targetActivity, TAG);
    }
}
